FROM golang:1.16 as build
RUN sed -i -E "s/[a-zA-Z0-9]+.debian.org/mirrors.aliyun.com/g" /etc/apt/sources.list \
    && apt-get update \
    && apt-get install libsasl2-dev
WORKDIR /app
ENV CGO_ENABLED=0 GOOS=linux GOARCH=amd64
ENV GOPROXY=https://goproxy.cn,direct
COPY huaxrobot  huaxrobot
WORKDIR /app/huaxrobot
RUN go mod download
RUN go build -v -o /huaxrobot ./main.go


FROM alpine
WORKDIR /app
RUN mkdir log
ADD huaxrobot/config config
COPY --from=build /huaxrobot .
ENTRYPOINT ["/app/huaxrobot"]